#|test
Is amazing.
Key Reference: RMarkdown - The Definitive Guide
PDF Printing Setup: tinytex
Free-form text.
Make text bold.
Make text italics.
Make text bold + italics.
Talk about code - the tidyverse is awesome
Unordered List:
Item 1
Item 2
Ordered List:
First point
Second point
More points
This is Tab 1
This is Tab 2
NIT Logo
Read in data and print to HTML. Notice effect of
df_print: paged option for HTML.
Try changing to df_print: default, or
kable or tibble. PDF prints normally.
Try changing results = "hide".
# Bike data
bikes_tbl <- readRDS("01_data/bikes_tbl.rds")
bikeshops_tbl <- readRDS("01_data/bikeshops_tbl.rds")
orderlines_tbl <- readRDS("01_data/orderlines_tbl.rds")
bike_orderlines_tbl <- orderlines_tbl %>%
left_join(bikes_tbl, by = c("product_id" = "bike_id")) %>%
left_join(bikeshops_tbl, by = c("customer_id" = "bikeshop_id")) %>%
mutate(total_price = price_euro * quantity)
bike_orderlines_tblWe can do data manipulations too. Try changing the YAML
code_folding option from none to
hide to show.
Plotting works as expected. Try changin:
out.height, out.width and
Knitting
Potential gotcha - Interactive plots (e.g. plotly)
will not display in PDF
Static Plots:
ggplot2.g <- sales_by_category_tbl %>%
ggplot(aes(category_2, total_revenue, fill = category_1)) +
# Geoms
geom_col() +
coord_flip() +
# Formatting
labs(
title = "Total Revenue by Category",
x = "", y = "", fill = ""
)
gRevenue by Category
Interactive plots:
ggplotly().Static Tables:
knitr package - knitr::kable() - Simple to
use, great with PDFgt package -
Really good for static tablestable_formatted_tbl <- sales_by_category_tbl %>%
rename_all(.funs = ~ str_replace(., "_", " ") %>%
str_to_title())
table_formatted_tbl %>% knitr::kable()| Category 2 | Category 1 | Total Revenue |
|---|---|---|
| Race | Road | 11509156 |
| Trail | Mountain | 8644966 |
| Triathlon Bike | Road | 5831716 |
| Cross-Country | Mountain | 5421144 |
| Endurance | Road | 5013423 |
| E-Mountain | E-Bikes | 4962946 |
| All-Road | Gravel | 3697923 |
| Enduro | Mountain | 3156837 |
| City | Hybrid / City | 2115482 |
| Cyclocross | Road | 1940532 |
| E-Gravel | E-Bikes | 1936489 |
| Downhill | Mountain | 1803970 |
| E-City | E-Bikes | 1509096 |
| E-Trekking | E-Bikes | 1500894 |
| E-Fitness | E-Bikes | 1039996 |
| Touring | Hybrid / City | 877736 |
| Adventure | Gravel | 702007 |
| Fat Bikes | Mountain | 391654 |
| Dirt Jump | Mountain | 371922 |
| E-Road | E-Bikes | 2919 |
Dynamic Tables:
df_print: paged option in YAML